package finalfinancialanalyst.business;

import java.io.Serializable;
import java.util.Date;

public class Transaction implements Serializable {
    
        private static final long serialVersionUID = 1L;
    
        private Account account;
 
	private boolean isExpenditure;
	 
	private Date time;
	 
	private String category;
	 
	private String name;
	 
	private String comment;
	 
	private Money transactionAmount;
	 
	private Money accountAmount;
	 
	private Location location;
        
        private long barcode;
	 
	public Transaction(Account account) {
            this.account = account;
            this.time = new Date();
            this.isExpenditure = true;
            this.accountAmount = new Money("0", account.getCurrency());
            this.location = new Location();
	}
	 
	public Money getAccountAmount() {
		return accountAmount;
	}
	 
	public void setTransactionAmount(Money money) {
             transactionAmount = money;
             accountAmount = money.convertTo(account.getCurrency());
	}
	 
	public Money getTransactionAmount() {
		return transactionAmount;
	}
	 
	public void setIsExpenditure(boolean exp) {
                isExpenditure = exp;
	}
	 
	public boolean getIsExpenditure() {
		return isExpenditure;
	}
	
        public String getIsExpenditureString() {
                if (isExpenditure) {
                    return "Expenditure";
                } else {
                    return "Income";
                }
        }
        
	public void setTime(Date time) {
                this.time = time;
	}
	 
	public Date getTime() {
		return time;
	}
        
        public long getBarcode() {
            return barcode;
        }
        
        public void setBarcode(long barcode) {
            this.barcode = barcode;
        }
	 
	public boolean setCategory(String cat) {
		category = cat;
                return true;
                //TODO checks
	}
	 
	public String getCategory() {
		return category;
	}
	 
	public boolean saveCurrentLocation() {
		return false;
	}
	 
	public void setLocation(Location loc) {
                location = loc;
	}
	 
	public Location getLocation() {
		return location;
	}
	 
	public void setName(String name) {
                this.name = name;
	}
	 
	public String getName() {
		return name;
	}
	 
	public void setComment(String com) {
                this.comment = com;
	}
	 
	public String getComment() {
		return comment;
	}
	 
}
 
